set.seed(1)
## Using 'Mult' with 'Exp' to constrain the first constituent multiplier
## to be non-negative
## Fit the "UNIDIFF" mobility model across education levels
unidiff <- gnm(Freq ~ educ*orig + educ*dest +
Mult(Exp(educ), orig:dest),
family = poisson, data = yaish, subset = (dest != 7))
if (FALSE) {
## (this example can take quite a while to run)
##
## Fitting two instances of a multiplicative interaction (i.e. a
## two-component interaction))
yield.scaled <- wheat$yield * sqrt(3/1000)
treatment <- factor(paste(wheat$tillage, wheat$summerCrop, wheat$manure,
wheat$N, sep = ""))
bilinear2 <- gnm(yield.scaled ~ year + treatment +
instances(Mult(year, treatment), 2),
family = gaussian, data = wheat)
formula(bilinear2)
## yield.scaled ~ year + treatment + Mult(year, treatment, inst = 1) +
## Mult(year, treatment, inst = 2)
}
Run the code above in your browser using DataLab